#include <iostream>
#include <vector>
#include "gmp.h"

struct point
{
    double x, y;

    bool operator !=(const point&) const;
    bool operator ==(const point&) const;
    bool operator <(const point&) const;
    bool operator <=(const point&) const;

    friend std::istream& operator >>(std::istream& input, point& a)
    {
        input >> a.x;
        input >> a.y;
        return input;
    }

    friend std::ostream& operator <<(std::ostream& output, const point& a)
    {
        output << a.x << " " << a.y;
        return output;
    }

    point(double x1, double y1): x(x1), y(y1) {}
    point(const point& a): x(a.x), y(a.y) {}
    point() {}
};

struct segment
{
    point first, second;
    segment(const point&, const point&);
    segment() {}

    bool operator ==(const segment&) const;

    friend std::istream& operator >>(std::istream& input, segment& a)
    {
        input >> a.first;
        input >> a.second;
        return input;
    }

    double slope;

    bool intersects_with_x(int) const;

    template <class T>
    void y_at(int, T&) const;
};

inline double sqrhypot(const point& a, const point& b)
{
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}